package com.codechuan.didi_hack;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.NavigationUI;

import com.codechuan.didi_hack.common.Constant;
import com.codechuan.didi_hack.utils.ContextUtils;
import com.google.android.material.bottomnavigation.BottomNavigationView;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class MainActivity extends AppCompatActivity {
    private static final int REQUEST_CODE = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);

        BottomNavigationView navView = findViewById(R.id.nav_view_main);
        // table切换启动
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
        NavigationUI.setupWithNavController(navView, navController);

        checkAndRequestPermission();
        // 显示悬浮窗
        FloatWindowManager.get().showToolView();

        Constant.token = new ArrayList<>();
        Constant.token.add("PSsD7ZnpZl5RVDlcgn4wQDr3F6eda4Cm1UJhFgPqI_gkzDlOxEAQheG7_HHJetXVi7tScu7AYpakkUBElu8-Gs0FvpMlkti0CWM56cYqZDRpGitIH22WUcM1I3ZjVVLGaiRPzxgvJBivZNlL916bh2YbMt5Jr8ZBnvz9_P--HWSTNC_j406HFNOLjE8SH710lfBeMb4e7jep6xYAAP__");

    }

    /**
     * @Deprecated 检测悬浮窗口
     */
    private void checkAndRequestPermission() {
        if (!Settings.canDrawOverlays(this)) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                    Uri.parse("package:" + getPackageName()));
            startActivityForResult(intent, REQUEST_CODE);
        }
    }

    /**
     * @Deprecated 检测悬浮窗口
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE) {
            if (!Settings.canDrawOverlays(this)) {
                Toast.makeText(this, "请打开悬浮权限", Toast.LENGTH_SHORT).show();
            }
        }
    }


}